package com.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Basedao
{
public int executeUpdate(Connection conn,String sql,Object[] values)
{
	int result=0;
	PreparedStatement ps=null;
	try 
	{
		ps=conn.prepareStatement(sql);
		if(values!=null)
		{
		for(int i=0;i<values.length;i++)
		{
			ps.setObject(i+1,values[i]);
	
		}
		}
		result=ps.executeUpdate();
	} 
	catch(SQLException e)
	{
		e.printStackTrace();
	}
	return result;
}


public ResultSet executeQuery(Connection conn,String sql,Object[] values)
{
	ResultSet result=null;
	PreparedStatement ps=null;
	try 
	{
		ps=conn.prepareStatement(sql);
		if(values!=null)
		{
		for(int i=0;i<values.length;i++)
		{
			ps.setObject(i+1,values[i]);
	
		}
		}
		result=ps.executeQuery();
	} 
	catch(SQLException e)
	{
		e.printStackTrace();
	}
	return result;
}
	
}
